<?php

namespace app\model;

use Carbon\Carbon;
use DateTimeInterface;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use support\Model;

/**
 *
 */
class OrderCard extends Model
{
    use HasFactory;

    protected $table = 'order_card';

    protected $guarded = [];


    public function getCreatedAtAttribute($value)
    {
        return Carbon::parse($value)->toDateTimeString();
    }


    /**
     * 为数组 / JSON 序列化准备日期。
     *
     * @param  \DateTimeInterface  $date
     * @return string
     */
    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }

    public function user()
    {
        return $this->hasOne(WxUser::class,"id",'user_id');
    }

    public function order()
    {
        return $this->hasOne(Order::class,"id","order_id");
    }

    public function games()
    {
        return $this->hasMany(Games::class,"order_id","order_id");
    }

    
}
